﻿using System;
using UnityEngine;

namespace ParticlePlayground
{
	// Token: 0x02000169 RID: 361
	[Serializable]
	public class MathManipulatorProperty
	{
		// Token: 0x06000898 RID: 2200 RVA: 0x000333C4 File Offset: 0x000315C4
		public virtual void Update(Vector3 position)
		{
			this.value3Position = position + this.value3;
		}

		// Token: 0x06000899 RID: 2201 RVA: 0x000333D8 File Offset: 0x000315D8
		public virtual Vector3 Evaluate(Vector3 inValue, float time)
		{
			if (this.clamp == MATHMANIPULATORCLAMP.ClampInValue)
			{
				inValue = this.Clamp(inValue);
			}
			Vector3 result;
			switch (this.type)
			{
			case MATHMANIPULATORTYPE.Sin:
				result = new Vector3((this.value3.x == 0f) ? inValue.x : this.ClampOut(inValue.x + Mathf.Sin(time * this.rate3.x) * this.value3.x), (this.value3.y == 0f) ? inValue.y : this.ClampOut(inValue.y + Mathf.Sin(time * this.rate3.y) * this.value3.y), (this.value3.z == 0f) ? inValue.z : this.ClampOut(inValue.z + Mathf.Sin(time * this.rate3.z) * this.value3.z));
				break;
			case MATHMANIPULATORTYPE.Cos:
				result = this.Clamp(new Vector3((this.value3.x == 0f) ? inValue.x : this.ClampOut(inValue.x + Mathf.Cos(time * this.rate3.x) * this.value3.x), (this.value3.y == 0f) ? inValue.y : this.ClampOut(inValue.y + Mathf.Cos(time * this.rate3.y) * this.value3.y), (this.value3.z == 0f) ? inValue.z : this.ClampOut(inValue.z + Mathf.Cos(time * this.rate3.z) * this.value3.z)));
				break;
			case MATHMANIPULATORTYPE.Lerp:
				result = this.Clamp(new Vector3((this.value3.x == 0f) ? inValue.x : Mathf.Lerp(inValue.x, this.ClampOut(this.value3.x), time * this.rate3.x), (this.value3.y == 0f) ? inValue.y : Mathf.Lerp(inValue.y, this.ClampOut(this.value3.y), time * this.rate3.y), (this.value3.z == 0f) ? inValue.z : Mathf.Lerp(inValue.z, this.ClampOut(this.value3.z), time * this.rate3.z)));
				break;
			case MATHMANIPULATORTYPE.Add:
				result = inValue + this.ClampOut(Vector3.Scale(this.value3, this.rate3) * time);
				break;
			case MATHMANIPULATORTYPE.Subtract:
				result = inValue - this.ClampOut(Vector3.Scale(this.value3, this.rate3) * time);
				break;
			default:
				result = inValue;
				break;
			}
			return result;
		}

		// Token: 0x0600089A RID: 2202 RVA: 0x00033758 File Offset: 0x00031958
		public virtual Vector3 EvaluatePosition(Vector3 inValue, float time)
		{
			if (this.clamp == MATHMANIPULATORCLAMP.ClampInValue)
			{
				inValue = this.Clamp(inValue);
			}
			Vector3 result;
			switch (this.type)
			{
			case MATHMANIPULATORTYPE.Sin:
				result = this.ClampPosition(new Vector3(inValue.x + Mathf.Sin(time * this.rate3.x) * this.value3.x, inValue.y + Mathf.Sin(time * this.rate3.y) * this.value3.y, inValue.z + Mathf.Sin(time * this.rate3.z) * this.value3.z));
				break;
			case MATHMANIPULATORTYPE.Cos:
				result = this.ClampPosition(new Vector3(inValue.x + Mathf.Cos(time * this.rate3.x) * this.value3.x, inValue.y + Mathf.Cos(time * this.rate3.y) * this.value3.y, inValue.z + Mathf.Cos(time * this.rate3.z) * this.value3.z));
				break;
			case MATHMANIPULATORTYPE.Lerp:
				result = this.ClampPosition(new Vector3(Mathf.Lerp(inValue.x, this.value3Position.x, time * this.rate3.x), Mathf.Lerp(inValue.y, this.value3Position.y, time * this.rate3.y), Mathf.Lerp(inValue.z, this.value3Position.z, time * this.rate3.z)));
				break;
			case MATHMANIPULATORTYPE.Add:
				result = this.ClampPosition(inValue + Vector3.Scale(this.value3, this.rate3) * time);
				break;
			case MATHMANIPULATORTYPE.Subtract:
				result = this.ClampPosition(inValue - Vector3.Scale(this.value3, this.rate3) * time);
				break;
			default:
				result = inValue;
				break;
			}
			return result;
		}

		// Token: 0x0600089B RID: 2203 RVA: 0x00033980 File Offset: 0x00031B80
		public virtual float Evaluate(float inValue, float time)
		{
			if (this.clamp == MATHMANIPULATORCLAMP.ClampInValue)
			{
				inValue = this.Clamp(inValue);
			}
			float result;
			switch (this.type)
			{
			case MATHMANIPULATORTYPE.Sin:
				result = ((this.value == 0f) ? inValue : this.ClampOut(Mathf.Sin(time * this.rate) * this.value));
				break;
			case MATHMANIPULATORTYPE.Cos:
				result = ((this.value == 0f) ? inValue : this.ClampOut(Mathf.Cos(time * this.rate) * this.value));
				break;
			case MATHMANIPULATORTYPE.Lerp:
				result = ((this.value == 0f) ? inValue : Mathf.Lerp(inValue, this.ClampOut(this.value), time * this.rate));
				break;
			case MATHMANIPULATORTYPE.Add:
				result = this.ClampOut(inValue + this.value * this.rate * time);
				break;
			case MATHMANIPULATORTYPE.Subtract:
				result = this.ClampOut(inValue - this.value * this.rate * time);
				break;
			default:
				result = inValue;
				break;
			}
			return result;
		}

		// Token: 0x0600089C RID: 2204 RVA: 0x00033AAC File Offset: 0x00031CAC
		public virtual float Clamp(float val)
		{
			if (this.clamp == MATHMANIPULATORCLAMP.None)
			{
				return val;
			}
			return Mathf.Clamp(val, this.clampFloor, this.clampCeil);
		}

		// Token: 0x0600089D RID: 2205 RVA: 0x00033AD0 File Offset: 0x00031CD0
		public virtual Vector3 Clamp(Vector3 val)
		{
			if (this.clamp == MATHMANIPULATORCLAMP.None)
			{
				return val;
			}
			val = new Vector3(Mathf.Clamp(val.x, this.clampFloor, this.clampCeil), Mathf.Clamp(val.y, this.clampFloor, this.clampCeil), Mathf.Clamp(val.z, this.clampFloor, this.clampCeil));
			return val;
		}

		// Token: 0x0600089E RID: 2206 RVA: 0x00033B3C File Offset: 0x00031D3C
		public virtual Vector3 ClampPosition(Vector3 val)
		{
			if (this.clamp == MATHMANIPULATORCLAMP.None)
			{
				return val;
			}
			val = new Vector3(Mathf.Clamp(val.x, this.value3Position.x + this.clampFloor, this.value3Position.x + this.clampCeil), Mathf.Clamp(val.y, this.value3Position.y + this.clampFloor, this.value3Position.y + this.clampCeil), Mathf.Clamp(val.z, this.value3Position.z + this.clampFloor, this.value3Position.z + this.clampCeil));
			return val;
		}

		// Token: 0x0600089F RID: 2207 RVA: 0x00033BF0 File Offset: 0x00031DF0
		public virtual float ClampOut(float val)
		{
			if (this.clamp != MATHMANIPULATORCLAMP.ClampOutValue)
			{
				return val;
			}
			return this.Clamp(val);
		}

		// Token: 0x060008A0 RID: 2208 RVA: 0x00033C08 File Offset: 0x00031E08
		public virtual Vector3 ClampOut(Vector3 val)
		{
			if (this.clamp != MATHMANIPULATORCLAMP.ClampOutValue)
			{
				return val;
			}
			return this.Clamp(val);
		}

		// Token: 0x060008A1 RID: 2209 RVA: 0x00033C20 File Offset: 0x00031E20
		public virtual MathManipulatorProperty Clone()
		{
			return new MathManipulatorProperty
			{
				type = this.type,
				property = this.property,
				clamp = this.clamp,
				clampFloor = this.clampFloor,
				clampCeil = this.clampCeil,
				value = this.value,
				value3 = this.value3,
				rate = this.rate,
				rate3 = this.rate3
			};
		}

		// Token: 0x040008B9 RID: 2233
		public MATHMANIPULATORTYPE type;

		// Token: 0x040008BA RID: 2234
		public MATHMANIPULATORPROPERTY property;

		// Token: 0x040008BB RID: 2235
		public MATHMANIPULATORCLAMP clamp;

		// Token: 0x040008BC RID: 2236
		public float clampCeil = 10f;

		// Token: 0x040008BD RID: 2237
		public float clampFloor;

		// Token: 0x040008BE RID: 2238
		public float value = 1f;

		// Token: 0x040008BF RID: 2239
		public Vector3 value3 = Vector3.up;

		// Token: 0x040008C0 RID: 2240
		public float rate = 1f;

		// Token: 0x040008C1 RID: 2241
		public Vector3 rate3 = Vector3.up;

		// Token: 0x040008C2 RID: 2242
		protected Vector3 value3Position;
	}
}
